package com.faeple.admin.service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.faeple.user.entity.UserDto;

public class AdminAuth extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		if(request.getSession().getAttribute("userDto") == null){
			response.sendRedirect("/");
			return false;
		}else{
			UserDto userDto = (UserDto)request.getSession().getAttribute("userDto");
			if(!userDto.getIdx().equals("35")){
				response.sendRedirect("/");
				return false;
			}
		}
		return true;
	}
}
